﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;
using Bike.Repository;
using Bike.Biz;
using Bike.Repository.Models;

namespace Bike.Forms.Categories
{
    public partial class AddCategoryForm : Telerik.WinControls.UI.RadForm
    {
        public AddCategoryForm()
        {
            InitializeComponent();
        }

        private void bntAddNew_Click(object sender, EventArgs e)
        {
            string name = txtName.Text.Trim();
            if (string.IsNullOrEmpty(name)) return;

            Category cat = new Category()
            {
                Name = name,
                Type = (int)CategoryTypes.Products
            };
            CategoryService service = new CategoryService();
            service.Add(cat);
            RadMessageBox.Show("Thêm danh mục mới thành công!", "Thêm Danh Mục", MessageBoxButtons.OK);
            this.Close();
        }

        private void bntClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
